package com.maimao.user.mapper.sys;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.maimao.model.user.sys.SysUser;
import com.maimao.model.user.sys.vo.SysUserVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.ArrayList;
import java.util.List;

/**
 * @author MaoLin Wang
 * @date 2020/11/30 9:19 下午
 */
@Mapper
public interface SysUserMapper extends BaseMapper<SysUser> {

    SysUser selectByIdCus(@Param("id") Integer userId);

    SysUser selectByUsernameValid(@Param("username") String username);

    List<SysUser> selectByNameLike(@Param("name") String name);


    void updateCus(SysUser sysUser);


    List<SysUser> selectByParam(@Param("realName") String realName,
                                @Param("mobile") String mobile,
                                @Param("status") Integer status,
                                @Param("path") String path);

    /**
     * 添加后台用户和角色的关联
     *
     * @param id      后台用户id
     * @param roleIds 角色id
     */
    int addUserRoleRecord(@Param("userId") Long id, @Param("roleIds") List<Integer> roleIds);
    int deleteRoleBatch(@Param("userId") Long userId, @Param("roleIds") List<Integer> roleIds);

    SysUser selectByUsernameSimple(String username);

    /**
     * 批量删除当前用户的所有角色
     *
     * @param id
     * @return
     */
    int deleteRecordBatch(Integer id);

    /**
     * 批量更新状态
     */
    void updateStatusBatch(@Param("ids") List<Integer> ids, @Param("status") Integer status);

    /**
     * 修改密码
     *
     * @param id
     * @param pass
     */
    void updatePass(@Param("id") Integer id, @Param("pass") String pass);

    List<Integer> queryByResourceIds(@Param("resourceIds") List<Integer> resourcesIds);

}
